package mango.functions;

import java.util.Collection;

public final class FuncArray {
    public static String[] toStringArray(Object[] obj) {
        String[] ret = new String[obj.length];
        for (int i = 0; i < obj.length; i++) {
            Object val = obj[i];
            if (val == null) {
                ret[i] = null;
            }
            else {
                ret[i] = String.valueOf(val);
            }
        }
        return ret;
    }
    
    public static String[] toStringArray(Collection<?> collection) {
        return toStringArray(collection.toArray());
    }
    
    public static int searchInArray(Object[] array, Object key) {
        for (int i = 0; i < array.length; i++) {
            if (key == array[i] || key.equals(array[i])) {
                return i;
            }
        }
        return -1;
    }
}
